package com.healthdata.controller;

import com.healthdata.service.HealthExpenditure2021Service;
import com.healthdata.vo.HealthExpenditure2021VO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/health-expenditure/2021")
public class HealthExpenditure2021Controller {

    @Autowired
    private HealthExpenditure2021Service healthExpenditure2021Service;

    /**
     * 获取所有健康支出数据
     * @return 健康支出数据列表
     */
    @GetMapping("/all")
    public List<HealthExpenditure2021VO> getAll() {
        return healthExpenditure2021Service.listAll();
    }

    /**
     * 根据ID获取健康支出数据
     * @param id 数据ID
     * @return 健康支出数据
     */
    @GetMapping("/{id}")
    public HealthExpenditure2021VO getById(@PathVariable Integer id) {
        return healthExpenditure2021Service.getById(id);
    }

    /**
     * 根据地区获取健康支出数据
     * @param region 地区名称
     * @return 健康支出数据列表
     */
    @GetMapping("/region")
    public List<HealthExpenditure2021VO> getByRegion(@RequestParam String region) {
        return healthExpenditure2021Service.listByRegion(region);
    }
}